class Solution(object):
    def findPermutation(self, s):
        """
        :type s: str
        :rtype: List[int]
        """
        count = 0
        n = len(s)
        out = [0] * (n + 1)
        left_index = 1
        index = 0
        while index < n:
            if s[index] == 'D':
                count += 1
            else:
                for i in range(count + 1):
                    out[index - i] = left_index
                    left_index += 1
                count = 0
            index += 1
        for i in range(count + 1):
            out[index - i] = left_index
            left_index += 1
        return out




data = Solution()
s = 'ID'
print(data.findPermutation(s))
